<template>
  <el-popover ref="compRef" v-model="value" v-bind="{ ...$props }">
    <template v-for="(_slot, slotName) in $slots" #[slotName]="slotProps">
      <slot :name="slotName" v-bind="slotProps" :key="slotName"></slot>
    </template>
  </el-popover>
</template>
<script setup lang="ts">
import { ref } from "vue";
import { PopoverProps } from "element-plus";
import { BasePopoverExpose } from "./types";
interface Props extends Partial<PopoverProps> {}

/** 需要按照官网文档设置默认值，否则表现效果和官网文档的不一致 */
withDefaults(defineProps<Props>(), {
  trigger: "hover",
  triggerKeys: ["Enter", "Space"],
  effect: "light",
  width: 150,
  placement: "bottom",
  showArrow: true,
  showAfter: 0,
  hideAfter: 200,
  autoClose: 0,
  tabindex: 0,
  teleported: true,
  appendTo: "body",
  persistent: true,
});

const value = defineModel();
const compRef = ref();

defineExpose<BasePopoverExpose>({
  // @ts-ignore
  instance: compRef,
});
</script>
<style lang="scss"></style>
